home *** CD-ROM | disk | FTP | other *** search
/ Merciful 2 / Merciful - Disc 2.iso / software / d / devioustools19.dms / devioustools19.adf / utils / 018.lzx / Palis / src / Main.c < prev    next >
C/C++ Source or Header  |  2007-02-12  |  2KB  |  119 lines

  1. /*
  2.     ·C·O·D·E·X· ·D·E·S·I·G·N· ·S·O·F·T·W·A·R·E·
  3.     presents
  4.  
  5.     PatchLibraries Utility
  6.  
  7.     FILE: Main.c
  8.     TASK:    mainloop
  9.  
  10.     (c)1995 by Hans Bühler
  11. */
  12.  
  13. #include    "pl.h"
  14.  
  15. // ---------------------------
  16. // defines
  17. // ---------------------------
  18.  
  19. // ---------------------------
  20. // datatypes
  21. // ---------------------------
  22.  
  23. // ---------------------------
  24. // proto
  25. // ---------------------------
  26.  
  27. static BOOL CheckQuit(BOOL request);
  28.  
  29. // ---------------------------
  30. // vars
  31. // ---------------------------
  32.  
  33. // ---------------------------
  34. // funx
  35. // ---------------------------
  36.  
  37. void MainLoop(void)
  38. {
  39.     ULONG                rec;
  40. #ifndef FINAL
  41.     ULONG                cxID;
  42.     CxMsg                *cxmsg;
  43. #endif
  44.     BOOL                quit    =    FALSE;
  45.  
  46.     // -- commodities ... ---
  47. #ifndef FINAL
  48.     ActivateCxObj(CxMain,TRUE);
  49. #endif
  50.     SetTaskPri(SysBase->ThisTask,PROG_PRI);
  51.  
  52.     do
  53.     {
  54.         rec    =    1 << SIGBREAKB_CTRL_C;            // you may also quit
  55.                                                             // PALIS by sending ^C signal to it !!!
  56. #ifndef FINAL
  57.         rec    |=    1 << CxPort->mp_SigBit;
  58. #endif
  59.         rec = Wait(rec);
  60.  
  61. #ifndef FINAL
  62.         if(rec & (1 << CxPort->mp_SigBit))
  63.             while((cxmsg = (CxMsg *)GetMsg(CxPort)) && !quit)
  64.             {
  65.                 cxID    =    CxMsgID(cxmsg);
  66.  
  67.                 ReplyMsg((APTR)cxmsg);
  68.  
  69.                 if(cxID == CXCMD_KILL)
  70.                     quit    =    CheckQuit(TRUE);
  71.                 else
  72.                     DisplayBeep(0);
  73.             }
  74. #endif
  75.  
  76.         if(!quit && rec & (1 << SIGBREAKB_CTRL_C))
  77.             quit    =    CheckQuit(TRUE);
  78.     }
  79.     while(!quit);
  80.  
  81.     SetTaskPri(SysBase->ThisTask,0);
  82. }
  83.  
  84.  
  85. /************************************************
  86.  * this routine checks whether it's possible to    *
  87.  * quit PALIS                                                *
  88.  ************************************************/
  89.  
  90. static BOOL CheckQuit(BOOL request)
  91. {
  92.     BOOL    quit    =    TRUE;
  93.  
  94.     ObtainSemaphore(&plBase.Sem);
  95.  
  96.     if(plBase.LibCnt)
  97.     {
  98.         if(!request ||
  99.             !Req(    "* WARNING *\n"
  100.                     "There are still %ld patches concerning %ld libraries\n"
  101.                     "known to " PROGNAME " !\n"
  102.                     "\n"
  103.                     "+----------------------------------------+\n"
  104.                     "| * IT IS VERY DANGEROUS TO QUIT NOW ! * |\n"
  105.                     "+----------------------------------------+\n"
  106.                     "\n"
  107.                     "Please refer to the manual before you proceed\n"
  108.                     "to quit " PROGNAME " !!!!",
  109.                     " Quit ;( | Cancel & be save ",
  110.                     (APTR)plBase.PatchCnt,(APTR)plBase.LibCnt,0,0))
  111.         {
  112.             quit    =    FALSE;
  113.         }
  114.     }
  115.  
  116.     ReleaseSemaphore(&plBase.Sem);
  117.  
  118.     return quit;
  119. }